home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 441 / aessrc12 / aesfsel3.s < prev    next >
Text File  |  1990-11-23  |  12KB  |  242 lines

  1.  
  2. ;*========================================================================
  3. ;*
  4. ;* AESFAST Public Domain GEM bindings.
  5. ;*  Maintenance:
  6. ;*   04/07/89 v1.2: This source file is new with this version.
  7. ;*            Also, the calculation of the location of the prompt on the
  8. ;*            screen has been changed.  It was placed one boxchar height
  9. ;*            down on the screen, putting it right below the menu bar.
  10. ;*            This didn't look too good on a big-monitor system, so now
  11. ;*            it is calculated by centering the box, then subtracting a
  12. ;*            fixed offset from the centered Y to make it appear right
  13. ;*            above the fsel'er box.  The offset is 9 character heights,
  14. ;*            (plus 2 extra char heights for the prompt itself), less
  15. ;*            2 pixels (just to line everything up real neat).
  16. ;*========================================================================
  17.  
  18.           .include  "aesfast.sh"
  19.           .include  "gemfast.sh"
  20.           .extern   _gl_apversion
  21.           .extern   aesblock
  22.  
  23. ;*************************************************************************
  24. ;*
  25. ;* Small extended fsel manager routine.
  26. ;*   This version emulates the TOS 1.4 fsel_exinput only to the point of
  27. ;*   putting up a prompt with the dialog.  
  28. ;*
  29. ;*************************************************************************
  30.  
  31. ;-------------------------------------------------------------------------
  32. ; fsel_smallexinput
  33. ;-------------------------------------------------------------------------
  34.  
  35. _fsel_smallexinput::
  36.  
  37.           .cargs    #8,.pinpath.l,.pinsel.l,.pbutton.l,.plabel.l
  38.           link      a6,#-4
  39.  
  40.           move.w    _gl_apversion,d0         ; Check the AES version.  If
  41.           cmp.w     #$0104,d0                ; it's $0104, we're running
  42.           beq.s     .ramaes                  ; on the RAM-based TOS 1.4
  43.           cmp.w     #$0130,d0                ; Else, if it's less than $0130
  44.           blt       simu_exinput             ; we have to simulate exinput.
  45. .ramaes:
  46.           move.l    .plabel(a6),d0           ; Swap the button and prompt
  47.           move.l    .pbutton(a6),.plabel(a6) ; string pointers to make the
  48.           move.l    d0,.pbutton(a6)          ; addrin stuff contiguous.
  49.  
  50.           AControl  91,0,2,3                 ; AES v1.3 & up: fsel_exinput
  51.           moveq.l   #-4,d2                   ; is a legal function, do it.
  52.           lea       .pinpath(a6),a0          ; a0 -> addrin
  53.           ACall     RET2HERE                 ; Call AES.
  54.  
  55.           move.l    .plabel(a6),d0           ; Swap the prompt string and
  56.           move.l    .pbutton(a6),.plabel(a6) ; button pointers back to how
  57.           move.l    d0,.pbutton(a6)          ; they were on entry.
  58.  
  59.           moveq.l   #-4,d1                   ; Return values from
  60.           lea       .pbutton(a6),a1          ; intout[] array to caller
  61.           jmp       (a0)                     ; via aes_return routine.
  62.  
  63. ;*************************************************************************
  64. ;* Simulation stuff...
  65. ;*  The following is the object tree that displays the prompt on 
  66. ;*  pre-TOS 1.4 systems, and the code to display that box.
  67. ;*************************************************************************
  68.  
  69. ;-------------------------------------------------------------------------
  70. ; Define variables which will be accessed as offsets from a5.
  71. ;  (Storage for these things is allocated in the text segment, below).
  72. ;-------------------------------------------------------------------------
  73.  
  74.           .abs                ; Define offsets from a5 base register...
  75.           
  76. prmpflag: ds.w      1         ; Flag: Has one-time object fixup been done?
  77.  
  78. treeptr:  ds.l      1         ; Ptr to tree: addrin for objc_draw() et. al.
  79. azero:    ds.w      1         ; A handy zero.
  80.  
  81. dialstuf: ds.w      1         ; Here things get a little ugly: The storage 
  82.           ds.w      2         ; from 'dialstuff' down is the intin array
  83. prmpstob: ds.w      1         ; for form_dial(FMD_FINISH).  From prmpstob
  84. prmpdpth: ds.w      1         ; down, it is also the intin array for
  85. prmpclip: ds.w      4         ; objc_draw().
  86.  
  87. ABS_SZ    =  *                ; Size of the a5-relative storage block.
  88.  
  89.           .text
  90.  
  91. absstore: dcb.b     ABS_SZ,0  ; Set aside memory for the a5-relative block.
  92.  
  93. ;-------------------------------------------------------------------------
  94. ; Define the TEDINFO and OBJECT structures for the prompt text. 
  95. ; (Macros for defining these things come from gemfast.sh).
  96. ;-------------------------------------------------------------------------
  97.  
  98. YSZ_PROMPT = 2
  99. YSZ_FSEL   = 9
  100. Y_OFFSET   = YSZ_PROMPT+YSZ_FSEL
  101.  
  102. prmptext: Teddef    0,0,0,3,0,TE_CNTR,$1180,0,1,31,0
  103. prmptree: Treedef   text
  104.           Objdef    ,-1,-1,-1,G_BOXTEXT,LASTOB,NORMAL,0,0,0,40,YSZ_PROMPT
  105.           
  106. ;-------------------------------------------------------------------------
  107. ; This routine lets us call AES more quickly than going through the
  108. ; routines in AESCOMN (and is better tailored to our needs here).
  109. ;-------------------------------------------------------------------------
  110.           
  111. aes_icall:
  112.            
  113.           movep.l   d0,control+1(a4)    ; fill in the control array (!),
  114.           move.l    a0,padrin(a4)       ; store the adrin ptr into aespb
  115.           move.l    a1,pintin(a4)       ; store the intin ptr into aespb
  116.           move.l    a2,pintout(a4)      ; store it into aespb
  117.           move.l    a4,d1               ; move the aespb pointer to the
  118.           move.w    #$C8,d0             ; interface register, also the AES
  119.           trap      #2                  ; function code, call AES, return
  120.           rts                           ; to the calling binding routine.
  121.  
  122. ;-------------------------------------------------------------------------
  123. ; simu_exinput - Simulate an exinput call on pre-TOS 1.4 systems.
  124. ;-------------------------------------------------------------------------
  125.  
  126. simuregs  reg       a2-a5               ; Registers we use.
  127.  
  128. simu_exinput:
  129.  
  130.           movem.l   #simuregs,-(sp)     ; Save registers.
  131.           lea       absstore(pc),a5     ; Load storage base register.
  132.           lea       aesblock,a4         ; Load aesblock base register.
  133.           
  134.           tas       prmpflag(a5)        ; Has first-time object tree fixup
  135.           bne.s     do_simulation       ; been done?  If so, continue below.
  136.  
  137. ;-------------------------------------------------------------------------
  138. ; Do the one-time object tree fixup:
  139. ;
  140. ;  - Plug in the various static string pointers.
  141. ;  - Plug in a couple of static integer values.
  142. ;  - Call rsrc_obfix  for resolution-specific x/y/w/h fixup.
  143. ;  - Call form_center to center box in the x coord & calc the clip area.
  144. ;  - Call graf_handle to get the height of a boxchar, and use this height
  145. ;    as the ob_y of the prompt box (and the clip area).  It just so happens
  146. ;    that the AES menu bar is one 'boxchar' in height, so this guarantees
  147. ;    we never overlay the menu bar with our prompt.
  148. ;-------------------------------------------------------------------------
  149.          
  150.           lea       azero(a5),a1        ; To do fixup, set string pointers
  151.           lea       prmptext(pc),a0     ; in TEDINFO and OBJECT structures.
  152.           move.l    a1,te_ptmplt(a0)    ; The template and valid strings
  153.           move.l    a1,te_pvalid(a0)    ; are NULL.  The ob_spec pointer
  154.           lea       prmptree(pc),a3     ; in the tree must point to the
  155.           move.l    a0,ob_spec(a3)      ; TEDINFO structure.
  156.           move.l    a3,treeptr(a5)      ; Save the tree pointer.
  157.  
  158.           move.w    #MAX_DEPTH,prmpdpth(a5)   ; Set objc_draw max-depth.
  159.           move.w    #FMD_FINISH,dialstuf(a5)  ; Set form_dial type.
  160.           
  161.           subq.l    #2,sp               ; allocate intout[1] 
  162.           move.l    sp,a2               ; a2 -> intout
  163.           lea       azero(a5),a1        ; a1 -> intin 
  164.           lea       treeptr(a5),a0      ; a0 -> adrin
  165.           AControl  114,1,1,1           ;    rsrc_obfix(prmptree,R_TREE);
  166.           bsr       aes_icall           ; do it.
  167.           addq.l    #2,sp               ; we don't care about intout[0].
  168.  
  169.           sub.w     #10,sp              ; Allocate intout[5] 
  170.           move.l    sp,a2               ; a2 -> intout
  171.           lea       treeptr(a5),a0      ; a0 -> addrin (prmptree)
  172.           AControl  54,0,5,1            ;    form_center(prmptree, &stack);
  173.           bsr       aes_icall           ; do it.
  174.           addq.l    #2,sp               ; We don't care about intout[0],
  175.           move.l    (sp)+,prmpclip(a5)  ; the rest of intout is the
  176.           move.l    (sp)+,prmpclip+4(a5); clip rectangle, save it.
  177.  
  178.           sub.w     #10,sp              ; Allocate intout[5], make a2 point
  179.           move.l    sp,a2               ; to it.  Do graf_handle(&stack).
  180.           AControl  77,0,5,0            ; The only value we want back from
  181.           bsr       aes_icall           ; the call is the height of a char
  182.           addq.l    #4,sp               ; which is in intout[2], put that
  183.           move.w    (sp)+,d0            ; in d0, throw everything else away.
  184.           addq.l    #4,sp               ; Calc the placement of the prompt
  185.           mulu      #Y_OFFSET,d0        ; box as Y_OFFSET characters up from
  186.           subq.w    #2,d0               ; the current (centered) location,
  187.           sub.w     d0,ob_y(a3)         ; set the ob_y value in the tree
  188.           sub.w     d0,prmpclip+2(a5)   ; and clip rectange to this value.
  189.  
  190. ;-------------------------------------------------------------------------
  191. ; Once the one-time stuff is done (and on all subsequent calls...) do
  192. ; the actual simulation of the TOS 1.4 exinput:
  193. ;
  194. ;  - Plug the prompt string pointer into the TEDINFO.
  195. ;  - The prompt string is placed in a box above the fsel dialog box on the
  196. ;    screen (but below the menu bar) before the system fsel'er is called.
  197. ;    The prompt is displayed inside a box, (it's a BOXTEXT object, which
  198. ;    is the entire tree).  The prompt is displayed with an objc_draw, and
  199. ;    removed by sending a redraw message (via form_dial).
  200. ;  - Call fsel_input() (the old one).
  201. ;  - Call form_dial() to send a redraw message to clear the prompt box.
  202. ;  - Return to caller.
  203. ;-------------------------------------------------------------------------
  204.  
  205. do_simulation:
  206.  
  207.           .cargs    #8,.pinpath.l,.pinsel.l,.pbutton.l,.plabel.l
  208.  
  209.           lea       prmptext(pc),a0     ; a0 -> te_ptext in TEDINFO.
  210.           move.l    .plabel(a6),(a0)    ; Set prompt text pointer.
  211.           
  212.           subq.l    #2,sp               ; allocate intout[1]
  213.           move.l    sp,a2               ; a2 -> intout
  214.           lea       prmpstob(a5),a1     ; a1 -> intin
  215.           lea       treeptr(a5),a0      ; a0 -> addrin
  216.           AControl  42,6,1,1            ;    objc_draw(prmptree,R_TREE....);
  217.           bsr       aes_icall           ; do it.
  218.           addq.l    #2,sp               ; throw away intout[0].
  219.           
  220.           lea       -4(a6),a2           ; a2 -> intout
  221.           lea       .pinpath(a6),a0     ; a0 -> addrin          
  222.           AControl  90,0,2,2            ;    fsel_input(inpath, insel,...);
  223.           bsr       aes_icall           ; do it.
  224.  
  225.           subq.l    #2,sp               ; allocate intout[1] for form_dial
  226.           move.l    sp,a2               ; a2 -> intout
  227.           lea       dialstuf(a5),a1     ; a1 -> intin
  228.           AControl  51,9,1,0            ;    form_dial(FMD_FINISH,...);
  229.           bsr       aes_icall           ; this sends a redraw message to
  230.           addq.l    #2,sp               ; clean up our prompt text box.
  231.  
  232.           movem.l   (sp)+,#simuregs     ; Restore working regs.
  233.           
  234.           move.l    .pbutton(a6),a1     ; Return the values from
  235.           move.w    -4(a6),d0           ; intout to the caller.
  236.           move.w    -2(a6),(a1)
  237.           unlk      a6
  238.           rts
  239.  
  240. ;         end of code
  241.  
  242.